import { defineStore } from 'pinia'
import dt from '@dt/dt'

const key_house = 'house_info'

export const houseStore = defineStore('house', {
  state: () => {
    return {
      info: dt.session.get(key_house)
    }
  },
  getters: {
    name: (state) => {
      return state.info?.houseName
    },
    id: (state) => {
      return state.info?.id ?? 0
    }
  },
  actions: {
    choice(item) {
      dt.session.set(key_house, item)
      this.info = item
    }
  }
})
